home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: April 18, 1997
- // Author: ramesh
- //
- // Description:
- // This script is defines the option box for the bevel surface menu item.
- //
- // Input Arguments:
- // int action
- // 0 - show the option box dialog
- // 1 - just execute the bevel operation
- //
- // Return Value:
- // None.
- //
-
-
- proc setOptionVars (int $forceFactorySettings)
- {
- bevelSetOptionVars( $forceFactorySettings );
- }
-
- global proc bevelVisibility()
- // Description:
- // Dim/show any bevel options as required by the number of edges
- // to bevel.
- //
- {
- int $nedges = 4;
- int $val = `radioButtonGrp -q -select bevelTopBottomRadioOptions`;
- if ( $val == 1 ) $nedges = 2;
- else if ( $val == 2 ) $nedges = 3;
- else if ( $val == 0 )
- {
- $val = `radioButtonGrp -q -select bevelBothOffRadioOptions`;
- if( $val == 1 ) $nedges = 4;
- else $nedges = 1;
- }
-
- if ( $nedges == 1 )
- {
- // dim all the options for bevel so that extrude is only left
- //
- checkBoxGrp -e -en 0 bevelJoinSrfBox;
- floatSliderGrp -e -en 0 bevelWidthFloatField;
- floatSliderGrp -e -en 0 bevelDepthFloatField;
- radioButtonGrp -e -en 0 bevelCornerRadioButtonGrp;
- radioButtonGrp -e -en 0 bevelEdgesRadio;
- }
- else
- {
- // show all the options for bevel
- //
- checkBoxGrp -e -en 1 bevelJoinSrfBox;
- floatSliderGrp -e -en 1 bevelWidthFloatField;
- floatSliderGrp -e -en 1 bevelDepthFloatField;
- radioButtonGrp -e -en 1 bevelCornerRadioButtonGrp;
- radioButtonGrp -e -en 1 bevelEdgesRadio;
- }
- }
-
- proc createBevelUI( string $parent, int $inTheTool, string $goToTool )
- //
- // Description :
- // Bevel operation options
- //
- {
- setParent $parent ;
-
- // layout for bevel options.
- //
- checkBoxGrp -ncb 1 -l "" -l1 "Attach Surfaces" -v1 on bevelJoinSrfBox;
-
- radioButtonGrp -nrb 2 -l "Bevel"
- -l1 "Top Side" -da1 2
- -l2 "Bottom Side" -da2 3
- -cc "bevelVisibility"
- bevelTopBottomRadioOptions;
-
- radioButtonGrp -nrb 2 -l "" -scl bevelTopBottomRadioOptions
- -l1 "Both" -da1 4
- -l2 "Off" -da2 1
- -cc "bevelVisibility"
- bevelBothOffRadioOptions;
-
- separator;
-
- floatSliderGrp -l "Bevel Width"
- -min 0.00001 -max 1.0 -fmn -10000.0 -fmx 10000.0
- bevelWidthFloatField;
- floatSliderGrp -l "Bevel Depth"
- -min 0.00001 -max 1.0 -fmn -10000.0 -fmx 10000.0
- bevelDepthFloatField;
- floatSliderGrp -l "Extrude Height"
- -min 0.00001 -max 1.0 -fmn -10000.0 -fmx 10000.0
- extrudeDepthFloatField;
-
- radioButtonGrp -nrb 2 -select 1 -l "Bevel Corners"
- -l1 "Straight" -da1 1
- -l2 "Circular Arcs" -da2 2
- bevelCornerRadioButtonGrp;
-
- radioButtonGrp -nrb 3
- -l "Bevel Cap Edge"
- -l1 "Convex"
- -l2 "Concave"
- -l3 "Straight"
- bevelEdgesRadio;
-
- separator;
-
- // layout for add curve range, create as polygons.
- //
- radioButtonGrp -nrb 2 -l "Use Tolerance"
- -l1 "Global"
- -l2 "Local"
- -on1 "tabLayout -e -selectTab noSlider useGlobalTolTab"
- -on2 "tabLayout -e -selectTab showSlider useGlobalTolTab"
- useGlobalTol;
-
- tabLayout -tabsVisible false useGlobalTolTab;
- columnLayout showSlider;
- floatSliderGrp -l "Tolerance"
- -min 0.00001 -max 1.0 -fmn 0.00001 -fmx 1000.0
- bevelToleranceFloatField;
- setParent ..;
- columnLayout noSlider;
- setParent ..;
- setParent ..;
-
- separator;
-
- radioButtonGrp -nrb 2 -label "Curve Range"
- -label1 "Complete" -da1 0
- -label2 "Partial" -da2 1 -select 1
- curveRangeRadioButtonGrp;
-
- if( `isTrue "SubdivUIExists"` && `isTrue "SurfaceUIExists"` ) {
- radioButtonGrp -nrb 4 -label "Output Geometry"
- -label1 "Nurbs" -da1 0
- -label2 "Polygons" -da2 1 -select 1
- -label3 "Subdiv" -da3 1
- -label4 "Bezier" -da4 1
- -cc1 "tabLayout -e -st bevelPolyOptionsNo bevelPolyOptions"
- -cc2 "tabLayout -e -st bevelPolyOptionsOK bevelPolyOptions"
- -cc3 "tabLayout -e -st bevelPolyOptionsSubdiv bevelPolyOptions"
- -cc4 "tabLayout -e -st bevelPolyOptionsBezier bevelPolyOptions"
- outputPolyRadioButtonGrp;
- }
- else if( `isTrue "SurfaceUIExists"` ) {
- radioButtonGrp -nrb 3 -label "Output Geometry"
- -label1 "Nurbs" -da1 0
- -label2 "Polygons" -da2 1 -select 1
- -label3 "Bezier" -da3 1
- -cc1 "tabLayout -e -st bevelPolyOptionsNo bevelPolyOptions"
- -cc2 "tabLayout -e -st bevelPolyOptionsOK bevelPolyOptions"
- -cc3 "tabLayout -e -st bevelPolyOptionsBezier bevelPolyOptions"
- outputPolyRadioButtonGrp;
- }
-
- separator;
-
- tabLayout -tabsVisible false bevelPolyOptions;
- string $par = `columnLayout bevelPolyOptionsOK`;
- nurbsToPolyAddOptions $par;
- setParent ..;
- columnLayout bevelPolyOptionsNo;
- setParent ..;
- columnLayout bevelPolyOptionsSubdiv;
- nurbsToSubdivAddOptions $par;
- setParent ..;
- columnLayout bevelPolyOptionsBezier;
- setParent ..;
- setParent ..;
-
- if( $inTheTool ) {
- separator;
- checkBoxGrp -ncb 2 -l "Tool Behavior"
- -l1 "Exit on Completion"
- -v1 off
- -on1 ("scriptCtx -e -euc true " + $goToTool)
- -of1 ("scriptCtx -e -euc false " + $goToTool)
-
- -l2 "Auto Completion"
- -v2 on
- -on2 ("scriptCtx -e -lac true " + $goToTool)
- -of2 ("scriptCtx -e -lac false " + $goToTool)
- scriptToolExtraWidget;
- }
- }
-
- proc string assembleCmd()
- //
- // Description :
- // To assemble bevel proc.
- //
- {
- setOptionVars(false);
- string $cmd = "bevelPreset" ;
- $cmd = $cmd + "(" ;
-
- int $history = `constructionHistory -q -tgl`;
- $cmd = $cmd + $history ;
- $cmd = $cmd + "," ;
-
- int $curveRangePartial = `optionVar -q bevelCurveRangePartial` ;
- $cmd = $cmd + $curveRangePartial ;
- $cmd = $cmd + "," ;
-
- int $polygons = `optionVar -q bevelOutputPolygons` ;
- if( !`isTrue "SurfaceUIExists"` ) $polygons = 1;
- $cmd = $cmd + $polygons ;
- $cmd = $cmd + "," ;
-
- float $tol = `optionVar -q bevelTolerance` ;
- if( `optionVar -q bevelUseGlobalTol` ) {
- $tol = `optionVar -q positionalTolerance`;
- }
- $cmd = $cmd + $tol ;
- $cmd = $cmd + "," ;
-
- int $bevelJoin = `optionVar -q bevelAttachSurfaces` ;
- $cmd = $cmd + $bevelJoin ;
- $cmd = $cmd + "," ;
-
- int $bevelSides = `optionVar -q bevelNSides` ;
- $cmd = $cmd + $bevelSides ;
- $cmd = $cmd + "," ;
-
- float $bevelWidth = `optionVar -q bevelWidth` ;
- $cmd = $cmd + $bevelWidth ;
- $cmd = $cmd + "," ;
-
- float $bevelDepth = `optionVar -q bevelDepth` ;
- $cmd = $cmd + $bevelDepth ;
- $cmd = $cmd + "," ;
-
- float $bevelExtrudeHt = `optionVar -q bevelExtrudeHeight` ;
- $cmd = $cmd + $bevelExtrudeHt ;
- $cmd = $cmd + "," ;
-
- int $bevelCorner = `optionVar -q bevelCorner` ;
- $cmd = $cmd + $bevelCorner ;
- $cmd = $cmd + "," ;
-
- int $bevelCapEdge = `optionVar -q bevelCapEdge` ;
- $cmd = $cmd + $bevelCapEdge ;
- $cmd = $cmd + ")" ;
-
- return $cmd ;
- }
-
- proc bevelOptions( int $inTheTool, string $goToTool )
- {
- // Name of the command for this option box.
- //
- string $commandName = "bevel";
-
- // Build the option box actions.
- //
- string $callback = ($commandName + "Callback");
- string $setup = ($commandName + "Setup");
-
- global string $gOptionBoxActionToolItem;
- $gOptionBoxActionToolItem = "modelWithToolBevel";
- global string $gOptionBoxActionToolItemCB;
- $gOptionBoxActionToolItemCB = "bevelToolScript 3";
-
- // Step 1: Get the option box.
- // ============================
- string $layout = getOptionBox();
- setParent $layout;
-
- // Step 2: Pass the command name to the option box.
- // =================================================
- setOptionBoxCommandName($commandName);
-
- // Step 3: Activate the default UI template.
- // ==========================================
- setUITemplate -pushTemplate DefaultTemplate;
-
- // Step 4: Create option box contents.
- // ===================================
-
- // Turn on the wait cursor.
- //
- waitCursor -state 1;
-
- tabLayout -scr true -tv false;
-
- string $parent = `columnLayout -adjustableColumn 1`;
-
- createBevelUI( $parent, $inTheTool, $goToTool );
-
- // Turn off the wait cursor.
- //
- waitCursor -state 0;
-
- // Step 5: Deactivate the default UI template.
- // ===========================================
- //
- setUITemplate -popTemplate;
-
- // Step 6: Customize the buttons.
- // ==============================
-
- // 'Apply' button.
- //
- string $applyBtn = getOptionBoxApplyBtn();
- if( $inTheTool ) {
- button -edit -l "Bevel Tool"
- -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"")
- $applyBtn;
- }
- else {
- button -edit -l "Bevel"
- -command ($callback + " " + $parent + " 1 \"" + $goToTool + "\"")
- $applyBtn;
- }
-
- // 'Save' button.
- //
- string $saveBtn = getOptionBoxSaveBtn();
- button -edit
- -command ($callback + " " + $parent + " 0 \"" +
- $goToTool + "\"; hideOptionBox")
- $saveBtn;
-
- // 'Reset' button.
- //
- string $resetBtn = getOptionBoxResetBtn();
- button -edit
- -command ($setup + " " + $parent + " 1 \"" + $goToTool + "\"")
- $resetBtn;
-
- // Step 7: Set the option box title.
- // =================================
- //
- if( $inTheTool ) {
- setOptionBoxTitle("Bevel Tool Options");
- }
- else {
- setOptionBoxTitle("Bevel Options");
- }
-
- // Step 8: Customize the 'Help' menu item text.
- // ============================================
- //
- setOptionBoxHelpTag( "Bevel" );
-
- // Step 9: Set the current values of the option box.
- // =================================================
- //
- eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\"");
-
- // Step 10: Show the option box.
- // =============================
- //
- showOptionBox();
- }
-
- proc string bevelHelp()
- {
- string $cmdHelp = "Command: Bevel - creates a bevelled surface. \n " ;
- string $selectHelp = "Selection: Select a curve or surface isoparm or curve on surface to bevel " ;
- return $cmdHelp+$selectHelp ;
- }
-
- global proc bevelSetup( string $parent,
- int $forceFactorySettings,
- string $goToTool)
- {
- // retrieve option settings.
- //
- setOptionVars($forceFactorySettings);
- bevelToolSetup( $forceFactorySettings, $goToTool );
-
- setParent $parent;
-
- // query and set controls for all the option vars.
- //
- float $bwidth = `optionVar -q bevelWidth` ;
- floatSliderGrp -e -v $bwidth bevelWidthFloatField ;
- if( $forceFactorySettings ) {
- floatSliderGrp -e
- -min 0.00001 -max 1.0 -fmn -10000.0 -fmx 10000.0
- bevelWidthFloatField ;
- }
-
- // bevel depth.
- //
- float $bdepth = `optionVar -q bevelDepth` ;
- floatSliderGrp -e -v $bdepth bevelDepthFloatField ;
- if( $forceFactorySettings ) {
- floatSliderGrp -e
- -min 0.00001 -max 1.0 -fmn -10000.0 -fmx 10000.0
- bevelDepthFloatField;
- }
-
- // extrude height.
- //
- float $edepth = `optionVar -q bevelExtrudeHeight` ;
- floatSliderGrp -e -v $edepth extrudeDepthFloatField ;
- if( $forceFactorySettings ) {
- floatSliderGrp -e
- -min 0.00001 -max 1.0 -fmn -10000.0 -fmx 10000.0
- extrudeDepthFloatField;
- }
-
- // global vs. local tolerance.
- int $useGlobalTol = `optionVar -q bevelUseGlobalTol`;
- radioButtonGrp -e -select (2 - $useGlobalTol) useGlobalTol;
-
- // bevel tolerance.
- //
- float $tol = `optionVar -q bevelTolerance` ;
- floatSliderGrp -e -v $tol bevelToleranceFloatField ;
- if( $forceFactorySettings ) {
- floatSliderGrp -e
- -min 0.00001 -max 1.0 -fmn 0.00001 -fmx 1000.0
- bevelToleranceFloatField;
- }
-
- if( $useGlobalTol == 1 ) {
- tabLayout -e -selectTab noSlider useGlobalTolTab;
- }
- else {
- tabLayout -e -selectTab showSlider useGlobalTolTab;
- }
-
- // attach the surfaces.
- //
- int $attach = `optionVar -q bevelAttachSurfaces` ;
-
- if( $attach == 1 ) {
- checkBoxGrp -edit -v1 true bevelJoinSrfBox ;
- } else {
- checkBoxGrp -edit -v1 0 bevelJoinSrfBox ;
- }
-
- // bevel corner.
- //
- int $bcorner = `optionVar -q bevelCorner`;
- radioButtonGrp -edit -select $bcorner bevelCornerRadioButtonGrp ;
-
- // cap.
- //
- int $bcap = `optionVar -q bevelCapEdge` ;
-
- if( $bcap == 1 ) {
- radioButtonGrp -edit -select 3 bevelEdgesRadio ;
- }
- else {
- radioButtonGrp -edit -select ($bcap-1) bevelEdgesRadio ;
- }
-
- // curve range on bevel inputs.
- //
- int $curveRangePartial = `optionVar -q bevelCurveRangePartial`+1 ;
- radioButtonGrp -edit -select $curveRangePartial curveRangeRadioButtonGrp ;
-
- // polygon output.
- //
- int $polygons = `optionVar -q bevelOutputPolygons`;
- if( `isTrue "SurfaceUIExists"` ) {
- if( `isTrue "SubdivUIExists"` && (3 != $polygons)) {
- radioButtonGrp -edit -select ($polygons+1)
- outputPolyRadioButtonGrp;
- }
- else {
- radioButtonGrp -edit -select 3 outputPolyRadioButtonGrp;
- }
- }
- else {
- $polygons = 1;
- }
-
- int $nedges = `optionVar -q bevelNSides` ;
-
- if( $nedges == 1 ) {
- int $ne = 2 ;
- radioButtonGrp -edit -select $ne bevelBothOffRadioOptions ;
- } else if( $nedges == 4 ) {
- int $ne = 1 ;
- radioButtonGrp -edit -select $ne bevelBothOffRadioOptions ;
- } else if( $nedges == 3 ) {
- int $ne = 2 ;
- radioButtonGrp -edit -select $ne bevelTopBottomRadioOptions ;
- } else if( $nedges == 2 ) {
- int $ne = 1 ;
- radioButtonGrp -edit -select $ne bevelTopBottomRadioOptions ;
- }
-
- // dim/show any options as required
- //
- bevelVisibility();
-
- switch( $polygons ) {
- case 0:
- default:
- tabLayout -e -st bevelPolyOptionsNo bevelPolyOptions;
- break;
- case 1:
- tabLayout -e -st bevelPolyOptionsOK bevelPolyOptions;
- break;
- case 2:
- tabLayout -e -st bevelPolyOptionsSubdiv bevelPolyOptions;
- break;
- }
-
- if( "" != $goToTool ) {
- checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool`
- scriptToolExtraWidget;
- checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool`
- scriptToolExtraWidget;
- }
-
- nurbsToPolySetup( $parent, $forceFactorySettings );
- nurbsToSubdivSetup( $parent, $forceFactorySettings );
- }
-
- global proc bevelCallback( string $parent, int $doIt, string $goToTool )
- {
- if( "" != $goToTool ) {
- optionVar -iv bevelEuc `scriptCtx -q -euc $goToTool`;
- optionVar -iv bevelLac `scriptCtx -q -lac $goToTool`;
- }
-
- setParent $parent ;
-
- // get Values from controls.
- //
- int $curveRangePartial = `radioButtonGrp -q -select curveRangeRadioButtonGrp` - 1 ;
- optionVar -intValue bevelCurveRangePartial $curveRangePartial ;
-
- if( `isTrue "SurfaceUIExists"` ) {
- int $polys = `radioButtonGrp -q -select outputPolyRadioButtonGrp`;
- if( (3 == $polys) && ! `isTrue "SubdivUIExists"` ) {
- $polys = 4;
- }
- optionVar -intValue bevelOutputPolygons ($polys-1) ;
- }
-
- // global vs. local
- int $useGlobalTol = 2 - `radioButtonGrp -q -select useGlobalTol`;
- optionVar -intValue bevelUseGlobalTol $useGlobalTol;
-
- float $value = `floatSliderGrp -q -v bevelToleranceFloatField` ;
- optionVar -floatValue bevelTolerance $value ;
-
- $value = `floatSliderGrp -q -v bevelWidthFloatField` ;
- optionVar -floatValue bevelWidth $value ;
-
- $value = `floatSliderGrp -q -v bevelDepthFloatField` ;
- optionVar -floatValue bevelDepth $value ;
-
- $value = `floatSliderGrp -q -v extrudeDepthFloatField` ;
- optionVar -floatValue bevelExtrudeHeight $value ;
-
- // attach surfaces or not.
- //
- int $val = `checkBoxGrp -q -v1 bevelJoinSrfBox` ;
- optionVar -intValue bevelAttachSurfaces $val ;
-
- // bevel corner type.
- //
- $val = `radioButtonGrp -q -select bevelCornerRadioButtonGrp` ;
- optionVar -intValue bevelCorner $val ;
-
- // bevel number of edges.
- //
- int $ne = 4 ;
- $val = `radioButtonGrp -q -select bevelTopBottomRadioOptions` ;
- if( $val == 1 ) $ne = 2 ;
- else if( $val == 2 ) $ne = 3 ;
- else if( $val == 0 ) {
- $val = `radioButtonGrp -q -select bevelBothOffRadioOptions` ;
- if( $val == 1 ) $ne = 4 ;
- else $ne = 1 ;
- }
- optionVar -intValue bevelNSides $ne ;
-
- int $nb = 1;
- $val = `radioButtonGrp -q -select bevelEdgesRadio`;
- if( $val < 3 ) {
- $nb = $val + 1;
- }
- optionVar -intValue bevelCapEdge $nb ;
-
- nurbsToPolyCallback( $parent, 0 );
- nurbsToSubdivCallback( $parent, 0 );
-
- if( 1 == $doIt ) {
- performBevel(0, $goToTool);
- string $tmpCmd = "performBevel(0, \"" + $goToTool + "\")";
- addToRecentCommandQueue $tmpCmd "Bevel";
- }
- else if( $doIt ) {
- setToolTo $goToTool;
- }
- }
-
- global proc string performBevel( int $action, string $goToTool )
- //
- // Description :
- // $action = 0 ==> do the command.
- // $action = 1 ==>show option box.
- // $action = 2 ==>drag to shelf.
- // $action = 3 ==>Show the tool option box
- {
- int $inTheTool = false;
- if( 3 == $action ) {
- $action = 1;
- $inTheTool = true;
- }
-
- string $cmd = "" ;
- switch( $action ) {
- case 0:
- $cmd = `assembleCmd` ;
- eval $cmd ;
- break ;
- case 1:
- bevelOptions( $inTheTool, $goToTool );
- break ;
- case 2:
- default:
- $cmd = `assembleCmd` ;
- break ;
- }
- return $cmd ;
- }
-
-